package com.regentsoft.cloudback.enterpriseAdmin.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.regentsoft.cloudback.base.BaseResp;
import com.regentsoft.cloudback.base.ResponseCode;
import io.swagger.annotations.ApiModelProperty;

/**
 * 统一返回类型
 * Created by work on 2017/11/28.
 *
 * @author lumr
 */
@JsonIgnoreProperties(value = "SUCCESS")
public class ResultResp<T> extends BaseResp {
    @ApiModelProperty(hidden = true)
    public static final ResultResp SUCCESS = new ResultResp();

    @ApiModelProperty(notes = "返回数据实体类")
    private T data;

    private ResultResp() {
        setCode(ResponseCode.SUCCESS);
        setMessage("成功");
    }

    public ResultResp(String message) {
        setCode(ResponseCode.FAIL);
        setMessage(message);
    }

    public ResultResp(Exception e) {
        setCode(ResponseCode.FAIL);
        setMessage(e.getMessage());
    }

    public ResultResp(T data) {
        this();
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
